package com.google.gwt.sample.hello.client.generated.business;

import java.util.Date;

import com.google.gwt.sample.hello.client.notgenerated.eventFramework.Accessor;
import com.google.gwt.sample.hello.client.notgenerated.eventFramework.Property;
import com.google.gwt.sample.hello.client.notgenerated.eventFramework.controler.BooleanToCheckbox;
import com.google.gwt.sample.hello.client.notgenerated.eventFramework.controler.DateToTextField;
import com.google.gwt.sample.hello.client.notgenerated.eventFramework.controler.StringToTextField;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.TextBox;


public class WidgetFactory {
	
	private static WidgetFactory eInstance = new WidgetFactory();

	public static WidgetFactory getEInstance() {
		return eInstance;
	}
	
	public TextBox createTextField_A_Name(final A a ){
		Accessor<String> accessorName = new Accessor<String>(){
			public String get() {
				return a.getName();
			}
			public void set(String newValue) {
				a.setName(newValue);
			}
		};
		Property<String> s = new Property<String>("name",accessorName);
		a.setPropertychangesupportname(s.getChanges());
		TextBox f = new TextBox();
		new StringToTextField(f,s);
		return f;
	}

	public CheckBox createCheckBox_A_Mariee(final A a ){
		Accessor<Boolean> accessorName = new Accessor<Boolean>(){
			public Boolean get() {
				return a.isMariee();
			}
			public void set(Boolean newValue) {
				a.setMariee(newValue);
			}
		};
		Property<Boolean> s = new Property<Boolean>("mariee",accessorName);
		a.setPropertychangesupportmariee(s.getChanges());
		CheckBox f = new CheckBox();
		new BooleanToCheckbox(f,s);
		return f;
	}
	public TextBox createTextField_A_DateNaissance(final A a ){
		Accessor<Date> accessorName = new Accessor<Date>(){
			public Date get() {
				return a.getDateNaissance();
			}
			public void set(Date newValue) {
				a.setDateNaissance(newValue);
			}
		};
		Property<Date> s = new Property<Date>("dateNaissance",accessorName);
		a.setPropertychangesupportdateNaissance(s.getChanges());
		TextBox f = new TextBox();
		new DateToTextField(f,s);
		return f;
	}
}
